/**
 * com.chaeron.GPS - An API for access to GPS devices.
 *
 *
 * Copyright (c) 2001, 2002 Chaeron Corporation,
 * All rights reserved.
 * 
 * Chaeron grants you a non-exclusive license to use, modify and re-distribute
 * this program under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version, provided that this copyright notice and 
 * license appear on all copies of the software.
 * 
 * Software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR
 * IMPLIED REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
 * HEREBY EXCLUDED. THE ENTIRE RISK ARISING OUT OF USING THE SOFTWARE IS ASSUMED
 * BY THE LICENSEE. See the GNU General Public License for more details.
 *
 * CHAERON AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
 * LICENSEE OR ANY THIRD PARTY AS A RESULT OF USING OR DISTRIBUTING SOFTWARE.
 * IN NO EVENT WILL CHAERON OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
 * PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL
 * OR PUNITIVE DAMAGES, HOWEVER CAUSED AN REGARDLESS OF THE THEORY OF LIABILITY,
 * ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF CHAERON HAS
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 * @version     1.02
 * @author      Andrzej Jan Taramina, Chaeron Corporation
 *              andrzej@chaeron.com
 */

package com.chaeron.GPS.exception;

import com.chaeron.platform.common.SerialPortError;

//***************************************************************************
//*
//*     Imports
//*
//***************************************************************************/

//***************************************************************************
//*
//*     GPSSerialPortException class definition
//*
//***************************************************************************/

/**
 * The GPSSerialPortException class
 *
 */

public class GPSSerialPortException extends GPSException
{
	
	//***************************************************************************
	//*
	//*     Constant definitions
	//*
	//***************************************************************************/
	
	/**
	 * The constant for a Serial Port Open Error Condition
	 */
	public final static int 		EXCEPTION_OPEN 			   	= EXCEPTION_CODE_UNKNOWN + 1;
	
	/**
	 * The constant for a Serial Port Close Error Condition
	 */
	public final static int 		EXCEPTION_CLOSE 			= EXCEPTION_CODE_UNKNOWN + 2;
	
	/**
	 * The constant for a Serial Port State Error Condition
	 */
	public final static int 		EXCEPTION_STATE 			= EXCEPTION_CODE_UNKNOWN + 3;
	
	/**
	 * The constant for a Serial Port Read Error Condition
	 */
	public final static int 		EXCEPTION_READ 				= EXCEPTION_CODE_UNKNOWN + 4;
	
	/**
	 * The constant for a Serial Port State Error Condition
	 */
	public final static int 		EXCEPTION_WRITE 			= EXCEPTION_CODE_UNKNOWN + 5;
	
	/**
	 * The constant for a Serial Port Packet Buffer Overrun Error Condition
	 */
	public final static int 		EXCEPTION_BUFFER_OVERRUN	= EXCEPTION_CODE_UNKNOWN + 6; 
	
	/**
	 * The constant for a Serial Port Read Check Error Condition
	 */
	public final static int 		EXCEPTION_READ_CHECK		= EXCEPTION_CODE_UNKNOWN + 7;
	
	/**
	 * The constant for a Serial Port Set Flow Control Error Condition
	 */
	public final static int 		EXCEPTION_SET_FLOW_CONTROL	= EXCEPTION_CODE_UNKNOWN + 8;
	
	/**
	 * The constant for a Serial Port Set Read Timeout Error Condition
	 */
	public final static int 		EXCEPTION_SET_READ_TIMEOUT	= EXCEPTION_CODE_UNKNOWN + 9;
	
	
	
	//***************************************************************************
	//*
	//*     Constructors
	//*
	//***************************************************************************/

	/**
	 * Constructs a <code>GPSSerialPortException</code>. This is thrown if a connection is
	 * open when it should be closed, or vice versa. 
	 *
	 *@param  code	the connection code for the exception
	 */
	
	public GPSSerialPortException( int code ) 
	{
		super( "GPS SP", code );
		
		exceptionMessages = new String[] {
			null,
			"Unable to open serial port",
			"Unable to close serial port",
			"Error reading serial port",
			"Error writing serial port",
			"Invalid serial port state",
			"Packet buffer overrun",
			"Read Check error on serial port",
			"Set Flow Control sertial port error",
			"Set Read Timeout sertial port error"
		}; 
	}
	
	
	/**
	 * Constructs a <code>GPSSerialPortException</code>. This is thrown if a connection is
	 * open when it should be closed, or vice versa. 
	 *
	 *@param  code	the connection code for the exception
	 *@param  error	the serial port error code
	 *@param  lineErr	the serial port line error flags
	 */
	
	public GPSSerialPortException( int code, int error, short lineErr ) 
	{
		super( "GPS SP, " + SerialPortError.getErrorMessage( error, lineErr ), code );
		
		exceptionMessages = new String[] {
			null,
			"Unable to open serial port",
			"Unable to close serial port",
			"Error reading serial port",
			"Error writing serial port",
			"Invalid serial port state",
			"Packet buffer overrun",
			"Read Check error on serial port"
		}; 
	}

}
